# Contributor: rubicon <rubicon@mailo.com>
# Maintainer: rubicon <rubicon@mailo.com>
pkgname=tcl-readline
pkgver=2.3.8
pkgrel=0
pkgdesc="GNU readline for Tcl"
url="https://github.com/flightaware/tclreadline"
arch="all"
license="BSD-3-Clause"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="readline-dev tcl-dev"
options="!check"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/flightaware/tclreadline/archive/refs/tags/v$pkgver.tar.gz
	manpage.patch
	"
builddir="$srcdir/tclreadline-$pkgver"

prepare() {
	default_prepare
	update_config_sub

	cp -av tclreadline.n.in tclreadline.3tcl.in
}

build() {
	./configure \
		--target="$CTARGET" \
		--build="$CBUILD" \
		--host="$CHOST" \
		--prefix=/usr \
		--without-tk
	make
}

dev() {
	default_dev

	mv -v "$subpkgdir"/usr/lib/libtclreadline.so "$pkgdir"/usr/lib/
	rmdir -v "$subpkgdir"/usr/lib
}

package() {
	make DESTDIR="$pkgdir" install
	(
		cd "$pkgdir"/usr/share/man/man3
		mv -v tclreadline.n tclreadline.3tcl
	)

	install -Dvm644 -t "$pkgdir"/usr/share/doc/$pkgname \
		AUTHORS COPYING ChangeLog INSTALL \
		README.md SCENARIO TODO sample.tclshrc
}

sha512sums="
0c5ce53a8f4cc222de013932698e442c63b36e3f07d10b962d127444f75c28b2caf7f06b5958150748f7a1d535c577c825b9a0dd525e077a348c3ff899a74e61  tcl-readline-2.3.8.tar.gz
1927f6656bd87118e8bef068eee12403f99c505aabae60b80b8353b3d918af29653f906e4ef6995808862eabe33fba8de3671be18371c7fd3b1fae6e1346faa3  manpage.patch
"
